#include "fuzzy_input.h"

FuzzyInput::FuzzyInput()
{
}


/*-------------------
// Controle do BSW //
-------------------*/
double FuzzyInput::lowBSW(double value)
{
    double result;

    if (value  <   60 )
    {
        result = 1.0;
    }
    if (value >= 60 && value < 75)
    {
        result = ((-(value-60)+15)/15);
        //qDebug() << result;
    }
    if(value >=75)
    {
            result =0.0;
    }

    return (result);
}

double FuzzyInput::mediumBSW(double value)
{
    double result;

    if (value  <   60 )
    {
        result = 0.0;
    }
    if (value >= 60 && value < 75)
    {
        result = ((value-60)/15);
        //qDebug() << result;
    }
    if(value >= 75 && value < 90)
    {
        result = ((-(value-75)+15)/15);
        //qDebug() << result;

    }
    if (value  >= 90 )
    {
        result = 0.0;
    }

    return (result);
}

double FuzzyInput::highBSW(double value)
{

    double result;

    if (value  <   75 )
    {
        result = 0.0;
    }
    if (value >= 75 && value < 90)
    {
        result = ((value-75)/15);
        //qDebug() << result;
    }
    if(value >=90)
    {
            result =1.0;
    }

    return (result);

}


/*----------------------
// Controle do Pessao //
----------------------*/
double FuzzyInput::lowPressure(double value)
{
    double result;

    if (value  <   30 )
    {
        result = 1.0;
    }
    if (value >= 30 && value < 43)
    {
        result = ((-(value-30)+13)/13);
        //qDebug() << result;
    }
    if(value >=43)
    {
            result =0.0;
    }

    return (result);
}

double FuzzyInput::mediumPressure(double value)
{
    double result;

    if (value  <   30 )
    {
        result = 0.0;
    }
    if (value >= 30 && value < 43)
    {
        result = ((value-30)/13);
        //qDebug() << result;
    }
    if(value >= 43 && value < 56)
    {
        result = ((-(value-43)+13)/13);
        //qDebug() << result;

    }
    if (value  >= 56 )
    {
        result = 0.0;
    }

    return (result);
}

double FuzzyInput::highPressure(double value)
{

    double result;

    if (value  <   43 )
    {
        result = 0.0;
    }
    if (value >= 43 && value < 56)
    {
        result = ((value-43)/13);
        //qDebug() << result;
    }
    if(value >=56)
    {
            result =1.0;
    }

    return (result);

}


/*-----------------------------
// Controle do Permeabilidade//
-----------------------------*/
double FuzzyInput::lowPermeability(double value)
{
    double result;

    if (value  <   15 )
    {
        result = 1.0;
    }
    if (value >= 15 && value < 25)
    {
        result = ((-(value-15)+10)/10);
        //qDebug() << result;
    }
    if(value >=25)
    {
            result =0.0;
    }

    return (result);
}

double FuzzyInput:: mediumPermeability(double value)
{
    double result;

    if (value  <   15 )
    {
        result = 0.0;
    }
    if (value >= 15 && value < 25)
    {
        result = ((value-15)/10);
        //qDebug() << result;
    }
    if(value >= 25 && value < 40)
    {
        result = ((-(value-25)+15)/15);
        //qDebug() << result;

    }
    if (value  >= 40 )
    {
        result = 0.0;
    }

    return (result);
}

double FuzzyInput::highPermeability(double value)
{

    double result;

    if (value  <   25 )
    {
        result = 0.0;
    }
    if (value >= 25 && value < 40)
    {
        result = ((value-25)/15);
        //qDebug() << result;
    }
    if(value >=40)
    {
            result =1.0;
    }

    return (result);

}


/*---------------------
// Controle do Netpay//
---------------------*/
double FuzzyInput::lowNetpay(double value)
{
    double result;

    if (value  <   1 )
    {
        result = 1.0;
    }
    if (value >= 1 && value < 3)
    {
        result = ((-(value-1)+2)/2);
        //qDebug() << result;
    }
    if(value >=3)
    {
            result =0.0;
    }

    return (result);
}

double FuzzyInput::mediumNetpay(double value)
{
    double result;

    if (value  <   1 )
    {
        result = 0.0;
    }
    if (value >= 1 && value < 3)
    {
        result = ((value-1)/2);
        //qDebug() << result;
    }
    if(value >= 3 && value < 5)
    {
        result = ((-(value-3)+2)/2);
        //qDebug() << result;

    }
    if (value  >= 5 )
    {
        result = 0.0;
    }

    return (result);
}

double FuzzyInput::highNetpay(double value)
{

    double result;

    if (value  <   3 )
    {
        result = 0.0;
    }
    if (value >= 3 && value < 5)
    {
        result = ((value-3)/2);
        //qDebug() << result;
    }
    if(value >=5)
    {
            result =1.0;
    }

    return (result);
}
